<extend name="./public/frame.html"/>
<block name="content">
	<blockquote class="layui-elem-quote search">
		<form action="" method="post">
		<div class="layui-inline">
			<select name="province_id" id="province_id" class="layui-input" lay-filter="province" style="width: 120px;" onclick="getProvinceList();">
				<option value="">请选择省份</option>
				<?php foreach($provinceList as $key=>$value):?>
				<option value="<?php echo $value['region_id'];?>" <?php if($disposition[0] == $value['region_id']):?>selected<?php endif;?>><?php echo $value['region_name'];?></option>
				<?php endforeach;?>
			</select>
		</div>
		<div class="layui-inline">
			<select name="city_id" id="city_id" class="layui-input" lay-filter="city_id" style="width: 120px;">
				<option value="">请选择城市</option>
				<?php foreach($city_list as $key=>$value):?>
				<option value="<?php echo $value['region_id'];?>" <?php if($value['region_id'] == $disposition[1]):?>selected<?php endif;?>><?php echo $value['region_name'];?></option>
				<?php endforeach;?>
			</select>
		</div>
		<div class="layui-inline">
			<select id="all_order" name="all_order" class="layui-input" style="width: 90px;">
				<option value="">全部订单</option>
				<option value="1" <?php if($all_order == 1):?>selected<?php endif;?>>普通订单</option>
				<option value="2" <?php if($all_order == 2):?>selected<?php endif;?>>测试订单</option>
			</select>
		</div>
		<div class="layui-input-inline">
			<div class="layui-inline">
				<input type="text" class="layui-input date" name="start_time" value="<?php echo $start_time;?>" placeholder="开始日期" style="width: 120px;">
			</div>
			<div class="layui-inline">
				<input type="text" class="layui-input date" name="end_time" value="<?php echo $end_time;?>" placeholder="结束日期" style="width: 120px;">
			</div>
		</div>
		<div class="layui-inline">
			<select name="type" id="type" class="layui-input" style="width: 120px;">
				<option value="column" <?php if($all_order == 'column'):?>selected<?php endif;?>>柱状图</option>
				<option value="line" <?php if($all_order == 'line'):?>selected<?php endif;?>>折线图</option>
			</select>
		</div>
		<div class="layui-inline">
			<input class="layui-btn" type="submit" value="搜索">
		</div>
		</form>
	</blockquote>
	<div id="container" style="min-width:400px;height:400px"></div>
	<div id="order_money" style="min-width:400px;height:400px"></div>
	<div id="timeOrderNum" style="min-width:400px;height:400px"></div>
	<script src="https://cdn.highcharts.com.cn/highcharts/highcharts.js"></script>
	<script>
		layui.use(['table','laydate' ],function () {
			var table = layui.table, laydate = layui.laydate;
			//下单时间检索
			lay('.date').each(function(){
				laydate.render({
					elem: this
					,type: 'date'
					,trigger: 'click'
				});
			});
		});
		var chart = Highcharts.chart('container',{
			chart: {
				type: '<?php echo $type;?>'
			},
			title: {
				text: '近<?php echo count($dateArray);?>天订单数据时时统计'
			},
			xAxis: {
				categories: [
						<?php foreach($dateArray as $key=>$value):?>
							'<?php echo $value;?>',
						<?php endforeach;?>
				],
				crosshair: true
			},
			yAxis: {
				min: 0,
				title: {
					text: '订单数量'
				}
			},
			tooltip: {
				// head + 每个 point + footer 拼接成完整的 table
				headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
				pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
						'<td style="padding:0"><b>{point.y}</b></td></tr>',
				footerFormat: '</table>',
				shared: true,
				useHTML: true
			},
			plotOptions: {
			<?php echo $type;?>: {
					borderWidth: 0,
					dataLabels: {
						// 开启数据标签

						enabled: <?php if($type == 'line'):?>true<?php else:?>false<?php endif;?>
					},
				},

			},
			series: [{
				name: '订单总数',
				data: [<?php echo $result['count'];?>]
			}, {
				name: '时时订单',
				data: [<?php echo $result['time_count'];?>]
			}, {
				name: '预约订单',
				data: [<?php echo $result['make_count'];?>]
			}, {
				name: '取消订单',
				data: [<?php echo $result['cancel_count'];?>]
			}, {
				name: '待接单订单',
				data: [<?php echo $result['wait_count'];?>]
			}, {
				name: '已接单订单',
				data: [<?php echo $result['take_count'];?>]
			}, {
				name: '已完成订单',
				data: [<?php echo $result['finish_count'];?>]
			}]
		});
		var chart = Highcharts.chart('order_money',{
			chart: {
				type: '<?php echo $type;?>'
			},
			title: {
				text: '近<?php echo count($dateArray);?>天订单金额'
			},
			xAxis: {
				categories: [
				<?php foreach($dateArray as $key=>$value):?>
					'<?php echo $value;?>',
				<?php endforeach;?>
		],
		crosshair: true
		},
		yAxis: {
			min: 0,
					title: {
				text: '金额（元）'
			}
		},
		tooltip: {
			// head + 每个 point + footer 拼接成完整的 table
			headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
					pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
			'<td style="padding:0"><b>{point.y:.2f}</b></td></tr>',
					footerFormat: '</table>',
					shared: true,
					useHTML: true
		},
		plotOptions: {
		<?php echo $type;?>: {
				borderWidth: 0,
						dataLabels: {
					// 开启数据标签

					enabled: <?php if($type == 'line'):?>true<?php else:?>false<?php endif;?>
				},
			},
		},
		series: [{
			name: '订单总额',
			data: [<?php echo $result['need_price'];?>]
		},{
			name: '优惠金额',
			data: [<?php echo $result['coupon_price'];?>]
		},]
	});
	var chart = Highcharts.chart('timeOrderNum',{
			chart: {
				type: '<?php echo $type;?>'
			},
			title: {
				text: '近<?php echo count($dateArray);?>天时间段订单数据量'
			},
			xAxis: {
				categories: [
				<?php foreach($timeArr as $key=>$value):?>
					'<?php echo $value;?>',
				<?php endforeach;?>
		],
		crosshair: true
		},
		yAxis: {
			min: 0,
					title: {
				text: '数量'
			}
		},
		tooltip: {
			// head + 每个 point + footer 拼接成完整的 table
			headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
					pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
			'<td style="padding:0"><b>{point.y}</b></td></tr>',
					footerFormat: '</table>',
					shared: true,
					useHTML: true
		},
		plotOptions: {
		<?php echo $type;?>: {
				borderWidth: 0,
						dataLabels: {
					// 开启数据标签
					enabled: <?php if($type == 'line'):?>true<?php else:?>false<?php endif;?>
				},
			},
		},
		series: [{
			name: '订单数量',
			data: [<?php echo $sumOrderNumStr;?>]
		}]
	});
		//选择省市切换
		function getProvinceList(){
			$("#city_id").empty();
			$("#city_id").append('<option value=>请选择城市</option>');
			var province_id = $("#province_id").val();
			$.ajax({
				url:'{:url("/admin/Franchisee/cityList")}',
				async:true,
				//dataType:'json',
				type:'post',
				data:{'province_id':province_id},
				success:function(res){
					$("#city_id").append(res);
				},
				error:function(e){
					layer.msg('请求错误');return false;
				}
			})
		};
	</script>
</block>
